#include <emscripten/bind.h>
#include "dwg.h"
#include "dwg_api.h"

using namespace emscripten;

EMSCRIPTEN_BINDINGS(libredwg_data) {
  enum_<Dwg_Version_Type>("Dwg_Version_Type")
    .value("R_INVALID", R_INVALID)
    .value("R_1_1", R_1_1)
    .value("R_1_2", R_1_2)
    .value("R_1_3", R_1_3)
    .value("R_1_4", R_1_4)
    .value("R_2_0b", R_2_0b)
    .value("R_2_0", R_2_0)
    .value("R_2_10", R_2_10)
    .value("R_2_21", R_2_21)
    .value("R_2_22", R_2_22)
    .value("R_2_4", R_2_4)
    .value("R_2_5", R_2_5)
    .value("R_2_6", R_2_6)
    .value("R_9", R_9)
    .value("R_9c1", R_9c1)
    .value("R_10", R_10)
    .value("R_11b1", R_11b1)
    .value("R_11b2", R_11b2)
    .value("R_11", R_11)
    .value("R_12", R_12)
    .value("R_13b1", R_13b1)
    .value("R_13b2", R_13b2)
    .value("R_13", R_13)
    .value("R_13c3", R_13c3)
    .value("R_14", R_14)
    .value("R_2000b", R_2000b)
    .value("R_2000", R_2000)
    .value("R_2000i", R_2000i)
    .value("R_2002", R_2002)
    .value("R_2004a", R_2004a)
    .value("R_2004b", R_2004b)
    .value("R_2004c", R_2004c)
    .value("R_2004", R_2004)
    .value("R_2007a", R_2007a)
    .value("R_2007b", R_2007b)
    .value("R_2007", R_2007)
    .value("R_2010b", R_2010b)
    .value("R_2010", R_2010)
    .value("R_2013b", R_2013b)
    .value("R_2013", R_2013)
    .value("R_2018b", R_2018b)
    .value("R_2018", R_2018)
    .value("R_2022b", R_2022b)
    .value("R_AFTER", R_AFTER);

  enum_<Dwg_Class_Stability>("Dwg_Class_Stability")
    .value("STABLE", DWG_CLASS_STABLE)
    .value("UNSTABLE", DWG_CLASS_UNSTABLE)
    .value("DEBUGGING", DWG_CLASS_DEBUGGING)
    .value("UNHANDLED", DWG_CLASS_UNHANDLED);

  enum_<Dwg_Entity_Sections>("Dwg_Entity_Sections")
    .value("ENTITY_SECTION", DWG_ENTITY_SECTION)
    .value("BLOCKS_SECTION", DWG_BLOCKS_SECTION)
    .value("EXTRA_SECTION", DWG_EXTRA_SECTION);

  enum_<Dwg_Object_Supertype>("Dwg_Object_Supertype")
    .value("SUPERTYPE_ENTITY", DWG_SUPERTYPE_ENTITY)
    .value("SUPERTYPE_OBJECT", DWG_SUPERTYPE_OBJECT);

  enum_<Dwg_Object_Type>("Dwg_Object_Type")
    .value("TYPE_UNUSED", DWG_TYPE_UNUSED)
    .value("TYPE_TEXT", DWG_TYPE_TEXT)
    .value("TYPE_ATTRIB", DWG_TYPE_ATTRIB)
    .value("TYPE_ATTDEF", DWG_TYPE_ATTDEF)
    .value("TYPE_BLOCK", DWG_TYPE_BLOCK)
    .value("TYPE_ENDBLK", DWG_TYPE_ENDBLK)
    .value("TYPE_SEQEND", DWG_TYPE_SEQEND)
    .value("TYPE_INSERT", DWG_TYPE_INSERT)
    .value("TYPE_MINSERT", DWG_TYPE_MINSERT)
    .value("TYPE_VERTEX_2D", DWG_TYPE_VERTEX_2D)
    .value("TYPE_VERTEX_3D", DWG_TYPE_VERTEX_3D)
    .value("TYPE_VERTEX_MESH", DWG_TYPE_VERTEX_MESH)
    .value("TYPE_VERTEX_PFACE", DWG_TYPE_VERTEX_PFACE)
    .value("TYPE_VERTEX_PFACE_FACE", DWG_TYPE_VERTEX_PFACE_FACE)
    .value("TYPE_POLYLINE_2D", DWG_TYPE_POLYLINE_2D)
    .value("TYPE_POLYLINE_3D", DWG_TYPE_POLYLINE_3D)
    .value("TYPE_ARC", DWG_TYPE_ARC)
    .value("TYPE_CIRCLE", DWG_TYPE_CIRCLE)
    .value("TYPE_LINE", DWG_TYPE_LINE)
    .value("TYPE_DIMENSION_ORDINATE", DWG_TYPE_DIMENSION_ORDINATE)
    .value("TYPE_DIMENSION_LINEAR", DWG_TYPE_DIMENSION_LINEAR)
    .value("TYPE_DIMENSION_ALIGNED", DWG_TYPE_DIMENSION_ALIGNED)
    .value("TYPE_DIMENSION_ANG3PT", DWG_TYPE_DIMENSION_ANG3PT)
    .value("TYPE_DIMENSION_ANG2LN", DWG_TYPE_DIMENSION_ANG2LN)
    .value("TYPE_DIMENSION_RADIUS", DWG_TYPE_DIMENSION_RADIUS)
    .value("TYPE_DIMENSION_DIAMETER", DWG_TYPE_DIMENSION_DIAMETER)
    .value("TYPE_POINT", DWG_TYPE_POINT)
    .value("TYPE_3DFACE", DWG_TYPE__3DFACE)
    .value("TYPE_POLYLINE_PFACE", DWG_TYPE_POLYLINE_PFACE)
    .value("TYPE_POLYLINE_MESH", DWG_TYPE_POLYLINE_MESH)
    .value("TYPE_SOLID", DWG_TYPE_SOLID)
    .value("TYPE_TRACE", DWG_TYPE_TRACE)
    .value("TYPE_SHAPE", DWG_TYPE_SHAPE)
    .value("TYPE_VIEWPORT", DWG_TYPE_VIEWPORT)
    .value("TYPE_ELLIPSE", DWG_TYPE_ELLIPSE)
    .value("TYPE_SPLINE", DWG_TYPE_SPLINE)
    .value("TYPE_REGION", DWG_TYPE_REGION)
    .value("TYPE_3DSOLID", DWG_TYPE__3DSOLID)
    .value("TYPE_BODY", DWG_TYPE_BODY)
    .value("TYPE_RAY", DWG_TYPE_RAY)
    .value("TYPE_XLINE", DWG_TYPE_XLINE)
    .value("TYPE_DICTIONARY", DWG_TYPE_DICTIONARY)
    .value("TYPE_OLEFRAME", DWG_TYPE_OLEFRAME)
    .value("TYPE_MTEXT", DWG_TYPE_MTEXT)
    .value("TYPE_LEADER", DWG_TYPE_LEADER)
    .value("TYPE_TOLERANCE", DWG_TYPE_TOLERANCE)
    .value("TYPE_MLINE", DWG_TYPE_MLINE)
    .value("TYPE_BLOCK_CONTROL", DWG_TYPE_BLOCK_CONTROL)
    .value("TYPE_BLOCK_HEADER", DWG_TYPE_BLOCK_HEADER)
    .value("TYPE_LAYER_CONTROL", DWG_TYPE_LAYER_CONTROL)
    .value("TYPE_LAYER", DWG_TYPE_LAYER)
    .value("TYPE_STYLE_CONTROL", DWG_TYPE_STYLE_CONTROL)
    .value("TYPE_STYLE", DWG_TYPE_STYLE)
    .value("TYPE_LTYPE_CONTROL", DWG_TYPE_LTYPE_CONTROL)
    .value("TYPE_LTYPE", DWG_TYPE_LTYPE)
    .value("TYPE_VIEW_CONTROL", DWG_TYPE_VIEW_CONTROL)
    .value("TYPE_VIEW", DWG_TYPE_VIEW)
    .value("TYPE_UCS_CONTROL", DWG_TYPE_UCS_CONTROL)
    .value("TYPE_UCS", DWG_TYPE_UCS)
    .value("TYPE_VPORT_CONTROL", DWG_TYPE_VPORT_CONTROL)
    .value("TYPE_VPORT", DWG_TYPE_VPORT)
    .value("TYPE_APPID_CONTROL", DWG_TYPE_APPID_CONTROL)
    .value("TYPE_APPID", DWG_TYPE_APPID)
    .value("TYPE_DIMSTYLE_CONTROL", DWG_TYPE_DIMSTYLE_CONTROL)
    .value("TYPE_DIMSTYLE", DWG_TYPE_DIMSTYLE)
    .value("TYPE_GROUP", DWG_TYPE_GROUP)
    .value("TYPE_MLINESTYLE", DWG_TYPE_MLINESTYLE)
    .value("TYPE_OLE2FRAME", DWG_TYPE_OLE2FRAME)
    .value("TYPE_DUMMY", DWG_TYPE_DUMMY)
    .value("TYPE_LONG_TRANSACTION", DWG_TYPE_LONG_TRANSACTION)
    .value("TYPE_LWPOLYLINE", DWG_TYPE_LWPOLYLINE)
    .value("TYPE_HATCH", DWG_TYPE_HATCH)
    .value("TYPE_XRECORD", DWG_TYPE_XRECORD)
    .value("TYPE_PLACEHOLDER", DWG_TYPE_PLACEHOLDER)
    .value("TYPE_VBA_PROJECT", DWG_TYPE_VBA_PROJECT)
    .value("TYPE_LAYOUT", DWG_TYPE_LAYOUT)
    .value("TYPE_PROXY_ENTITY", DWG_TYPE_PROXY_ENTITY)
    .value("TYPE_PROXY_OBJECT", DWG_TYPE_PROXY_OBJECT);

  enum_<Dwg_Object_Type_r11>("Dwg_Object_Type_r11")
    .value("DWG_TYPE_UNUSED_r11", DWG_TYPE_UNUSED_r11)
    .value("DWG_TYPE_LINE_r11", DWG_TYPE_LINE_r11)
    .value("DWG_TYPE_POINT_r11", DWG_TYPE_POINT_r11)
    .value("DWG_TYPE_CIRCLE_r11", DWG_TYPE_CIRCLE_r11)
    .value("DWG_TYPE_SHAPE_r11", DWG_TYPE_SHAPE_r11)
    .value("DWG_TYPE_REPEAT_r11", DWG_TYPE_REPEAT_r11)
    .value("DWG_TYPE_ENDREP_r11", DWG_TYPE_ENDREP_r11)
    .value("DWG_TYPE_TEXT_r11", DWG_TYPE_TEXT_r11)
    .value("DWG_TYPE_ARC_r11", DWG_TYPE_ARC_r11)
    .value("DWG_TYPE_TRACE_r11", DWG_TYPE_TRACE_r11)
    .value("DWG_TYPE_LOAD_r11", DWG_TYPE_LOAD_r11)
    .value("DWG_TYPE_SOLID_r11", DWG_TYPE_SOLID_r11)
    .value("DWG_TYPE_BLOCK_r11", DWG_TYPE_BLOCK_r11)
    .value("DWG_TYPE_ENDBLK_r11", DWG_TYPE_ENDBLK_r11)
    .value("DWG_TYPE_INSERT_r11", DWG_TYPE_INSERT_r11)
    .value("DWG_TYPE_ATTDEF_r11", DWG_TYPE_ATTDEF_r11)
    .value("DWG_TYPE_ATTRIB_r11", DWG_TYPE_ATTRIB_r11)
    .value("DWG_TYPE_SEQEND_r11", DWG_TYPE_SEQEND_r11)
    .value("DWG_TYPE_JUMP_r11", DWG_TYPE_JUMP_r11)
    .value("DWG_TYPE_POLYLINE_r11", DWG_TYPE_POLYLINE_r11)
    .value("DWG_TYPE_VERTEX_r11", DWG_TYPE_VERTEX_r11)
    .value("DWG_TYPE_3DLINE_r11", DWG_TYPE_3DLINE_r11)
    .value("DWG_TYPE_3DFACE_r11", DWG_TYPE_3DFACE_r11)
    .value("DWG_TYPE_DIMENSION_r11", DWG_TYPE_DIMENSION_r11)
    .value("DWG_TYPE_VIEWPORT_r11", DWG_TYPE_VIEWPORT_r11)
    .value("DWG_TYPE_UNKNOWN_r11", DWG_TYPE_UNKNOWN_r11);

  enum_<Dwg_Error>("Dwg_Error")
    .value("DWG_NOERR", DWG_NOERR)
    .value("DWG_ERR_WRONGCRC", DWG_ERR_WRONGCRC)
    .value("DWG_ERR_NOTYETSUPPORTED", DWG_ERR_NOTYETSUPPORTED)
    .value("DWG_ERR_UNHANDLEDCLASS", DWG_ERR_UNHANDLEDCLASS)
    .value("DWG_ERR_INVALIDTYPE", DWG_ERR_INVALIDTYPE)
    .value("DWG_ERR_INVALIDHANDLE", DWG_ERR_INVALIDHANDLE)
    .value("DWG_ERR_INVALIDEED", DWG_ERR_INVALIDEED)
    .value("DWG_ERR_VALUEOUTOFBOUNDS", DWG_ERR_VALUEOUTOFBOUNDS)
    .value("DWG_ERR_CLASSESNOTFOUND", DWG_ERR_CLASSESNOTFOUND)
    .value("DWG_ERR_SECTIONNOTFOUND", DWG_ERR_SECTIONNOTFOUND)
    .value("DWG_ERR_PAGENOTFOUND", DWG_ERR_PAGENOTFOUND)
    .value("DWG_ERR_INTERNALERROR", DWG_ERR_INTERNALERROR)
    .value("DWG_ERR_INVALIDDWG", DWG_ERR_INVALIDDWG)
    .value("DWG_ERR_IOERROR", DWG_ERR_IOERROR)
    .value("DWG_ERR_OUTOFMEM", DWG_ERR_OUTOFMEM);

  enum_<Dwg_Hdl_Code>("Dwg_Hdl_Code")
    .value("DWG_HDL_OWNER", DWG_HDL_OWNER)
    .value("DWG_HDL_SOFTOWN", DWG_HDL_SOFTOWN)
    .value("DWG_HDL_HARDOWN", DWG_HDL_HARDOWN)
    .value("DWG_HDL_SOFTPTR", DWG_HDL_SOFTPTR)
    .value("DWG_HDL_HARDPTR", DWG_HDL_HARDPTR);

  enum_<DWG_SECTION_TYPE>("DWG_SECTION_TYPE")
    .value("SECTION_UNKNOWN", SECTION_UNKNOWN)
    .value("SECTION_HEADER", SECTION_HEADER)
    .value("SECTION_AUXHEADER", SECTION_AUXHEADER)
    .value("SECTION_CLASSES", SECTION_CLASSES)
    .value("SECTION_HANDLES", SECTION_HANDLES)
    .value("SECTION_TEMPLATE", SECTION_UNKNOWN)
    .value("SECTION_OBJFREESPACE", SECTION_HEADER)
    .value("SECTION_OBJECTS", SECTION_AUXHEADER)
    .value("SECTION_REVHISTORY", SECTION_CLASSES)
    .value("SECTION_SUMMARYINFO", SECTION_HANDLES)
    .value("SECTION_PREVIEW", SECTION_PREVIEW)
    .value("SECTION_APPINFO", SECTION_APPINFO)
    .value("SECTION_APPINFOHISTORY", SECTION_APPINFOHISTORY)
    .value("SECTION_FILEDEPLIST", SECTION_FILEDEPLIST)
    .value("SECTION_SECURITY", SECTION_SECURITY)
    .value("SECTION_VBAPROJECT", SECTION_VBAPROJECT)
    .value("SECTION_SIGNATURE", SECTION_SIGNATURE)
    .value("SECTION_ACDS", SECTION_ACDS)
    .value("SECTION_INFO", SECTION_INFO)
    .value("SECTION_INFO", SECTION_SYSTEM_MAP);

  enum_<RESBUF_VALUE_TYPE>("RESBUF_VALUE_TYPE")
    .value("DWG_VT_INVALID", DWG_VT_INVALID)
    .value("DWG_VT_STRING", DWG_VT_STRING)
    .value("DWG_VT_POINT3D", DWG_VT_POINT3D)
    .value("DWG_VT_REAL", DWG_VT_REAL)
    .value("DWG_VT_INT16", DWG_VT_INVALID)
    .value("DWG_VT_INT32", DWG_VT_STRING)
    .value("DWG_VT_INT8", DWG_VT_POINT3D)
    .value("DWG_VT_BINARY", DWG_VT_REAL)
    .value("DWG_VT_HANDLE", DWG_VT_INVALID)
    .value("DWG_VT_OBJECTID", DWG_VT_STRING)
    .value("DWG_VT_BOOL", DWG_VT_POINT3D)
    .value("DWG_VT_INT64", DWG_VT_REAL);
}
